<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="0">
    <!-- BEGIN 全局样式 -->
    <link rel="stylesheet" href="../../../lib/bootstrap-3.3.7-dist/css/bootstrap.min.css" type="text/css"/>
    <link rel="stylesheet" href="../../../lib/jedate/skin/jedate-blue.css">
    <link rel="stylesheet" href="../../../css/reset-diy.css" type="text/css">
    <title>历史预警列表</title>
</head>
<body>
<div class="container-fluid pt-20">
    <!--<div class="table-responsive mt-35">-->
    <!--
    <div class="row mb-30 text-right">
        <div class="col-md-3 col-sm-3">
            <input id="dateStart" class="form-control" type="text" readonly placeholder="开始时间">
        </div>
        <div class="col-md-3 col-sm-3">
            <input id="dateEnd" class="form-control" type="text" readonly placeholder="结束时间">
        </div>

        <div class="col-md-2 col-sm-2"><input type="text" class="people form-control" placeholder="工号,人名"></div>

        <div class="col-md-2 col-sm-2">
            <select class="form-control" style="display: inline-block">
                <option value="">全部状态</option>
                <option value="">迟到</option>
                <option value="">早退</option>
                <option value="">旷工</option>
            </select>
        </div>
        <span class="btn-search btn btn-success ml-10 mr-15"><span class="glyphicon glyphicon-search"></span> 查询</span>
    </div>
-->
    <div class="text-right mt-25 mb-5 f-16">总共 <span class="total-num">0</span> 条</div>
    <table id="table-warning" class="table table-bordered table-striped table-hover text-center">
        <thead>
        <tr class="text-c">
            <th>序号</th>
            <th>姓名</th>
            <!--<th>工号</th>-->
            <th>预警信息</th>
            <th>时间</th>
        </tr>
        </thead>
        <tbody></tbody>
    </table>
    <div id="dataVessel" style='margin-top:30px;text-align:center;width:100%;font-size:18px;'></div>
    <div id="paging-bar" style="text-align:center;margin-top: 15px;"></div>

    <!--</div>-->
    <!--<div class="bk-gray mt-50 center-block text-c f-30" style="width:500px;height:500px;line-height:500px;">预警管理</div>-->
</div>

<!--核心脚本sss-->
<script src="../../../lib/jquery/1.9.1/jquery.js" type="text/javascript" charset="utf-8"></script>
<!--[if lt IE 9]>
<script src="../../../js/excanvas.min.js"></script>
<script src="../../../js/respond.min.js"></script>
<![endif]-->
<!--加密插件sss 必须放在jquery.myPlugIn_v1.0.js前面-->
<script src="../../../js/common/jsrsasign-all-min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/common/crypto-js.min.js" type="text/javascript" charset="utf-8"></script>
<!--加密插件eee-->

<!--<script src="../../js/bootstrap.min.js" type="text/javascript"></script>-->
<script src="../../../lib/layer/2.4/layer.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../lib/laypage/1.2/laypage.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../lib/jedate/dist/jedate.min.js"></script>
<script src="../../../js/work-box.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/common/jquery.myPlugIn_v1.0.js" type="text/javascript" charset="utf-8"></script>
<script>
    var T = new Extend_base();
    jQuery(document).ready(function () {
        function Warning() {
            // this.dateInit();
            this.getData();
            this.search();
        }

        Warning.prototype = {
            dataVessel: $("#dataVessel"),
            dateInit: function () {
                jeDate("#dateStart", {});
                jeDate("#dateEnd", {});
            },
            getData: function () {
                var _this = this;
                _this.dataVessel.text("正在获取数据...");

                var url, param, method;
                url = url_join("warning/list");
                method = "post";
                param = {};

                T.ajaxPaging(url, method, param, function (res) {
                    var data = typeof res == "object" ? res.data : [];

                    if (data.items.length > 0) {
                        _this.render(data);
                        _this.dataVessel.text("");

                        T.pagingAll(
                            {
                                bar: 'paging-bar',
                                sum: data.total_pages,
                                callback: function (obj) {
                                    param.page = obj.curr;
                                    T.ajaxSecret(url, method, param, function (res) {
                                        var data = res.data;
                                        _this.dataVessel.text("");
                                        if (data.items.length > 0) {
                                            _this.render(data);
                                        } else if (data.items.length == 0) {
                                            _this.dataVessel.text("没有找到相关数据..");
                                        }
                                    });
                                },
                            }
                        );
                    } else if (data.items.length == 0) {
                        $("#paging-bar").hide();
                        _this.dataVessel.text("没有找到相关数据..");
                    }
                });
            },
            render: function (obj) {
                var data = obj.items;
                var table = $("#table-warning");
                table.find("tbody").html("");
                $(".total-num").text(obj.total_items);
                $.each(data, function (i, v) {
                    var tr = $("<tr>" +
                        "<td>"+ ( obj.limit  *  (obj.current-1) + 1+i) +"</td>" +
                        "<td>" + v.username + "</td>" +
                        // "<td>" + v.no + "</td>" +
                        "<td>" + v.message + "</td>" +
                        "<td>" + v.created_at + "</td>" +
                        "</tr>");
                    table.find("tbody").append(tr);
                });
            },
            search: function () {
                var _this = this;

                $(".btn-search").on("click", function () {
                    _this.dataVessel.text("正在获取数据...");
                    $("#table-warning").find("tbody").html("");

                    var url, param, method;
                    url = url_join("warning/list");
                    method = "post";
                    param = {keyword: $(".people").val()};

                    T.ajaxPaging(url, method, param, function (res) {
                        var data = typeof res == "object" ? res.data : [];

                        if (data.items.length > 0) {
                            _this.render(data.items);
                            _this.dataVessel.text("");

                            T.pagingAll(
                                {
                                    bar: 'paging-bar',
                                    sum: data.total_pages,
                                    callback: function (obj) {
                                        param.page = obj.curr;
                                        T.ajaxSecret(url, method, param, function (res) {
                                            var data = res.data.items;
                                            _this.dataVessel.text("");
                                            if (data.length > 0) {
                                                _this.render(data);
                                            } else if (data.length == 0) {
                                                _this.dataVessel.text("没有找到相关数据..");
                                            }
                                        });
                                    },
                                }
                            );
                        } else if (data.items.length == 0) {
                            $("#paging-bar").hide();
                            _this.dataVessel.text("没有找到相关数据..");
                        }
                    });
                });
            }
        };
        new Warning();
    });
</script>
</body>
</html>